module main;

import std.stdio;
import std.stdint;
import std.getopt;

immutable VERSION = "0.1.0";

int main(string [] args)
{

	ubyte aboundry = 0;
	uint32_t base = 0;
	bool bUsage = false, bDiscardLocal = false;
	bool bFatalWarn = false, bGCSection = false;

	getopt(args,
		"align", &aboundry,
		"base-address", &base,
		"help|h", &bUsage,
	       "discard-local", &bDiscardLocal,
	       "fatal-warnings", &bFatalWarn,
	       "gc-sections", &bGCSection
	       );

	if (bUsage) {
		usage();
		return 0;
	}


	return 0;
}

void banner()
{
	writeln("sdld v",VERSION);
	writeln(__VERSION__);
	writeln("Copyright 2013 Open Design Strategies, LLC");
	writeln("A super-fast, optimizing linker and loader for MUNIX and SIDEARM");
	writeln("");
}
void usage()
{
	banner();
	writeln("sdld [options] <input.o>...");
	writeln("where [options] are as follows:");
	writeln("--align <boundary>          Align object code/data on <boundary> bytes");
	writeln("--base-address <addr>       Set base address of image to <addr>");
	writeln("--define-symbol <sym>,<addr>Creates a global symbol in the output file at <addr>");
	writeln("--discard-local             Discard all local symbols");
	writeln("-e, --entry <entry>         Specify alternative entry point");
	writeln("--endian <little|big>       Link little or big-endian object file");
	writeln("--fatal-warnings            Treat all warnings as errors");
	writeln("--heap-max <bytes>          Sets the size of the local heap");
	writeln("--gc-sections               Enable garbage collection of sections");
	writeln("--hash-size <buckets>       Set default size of linker's hash tables to prime #");
	writeln("-h, --help                  Display this help information");
	writeln("-L, -libs <libs>            Supply path to search for libraries and object files");
	writeln("--list-global-symbols       List all global and exported symbols");
	writeln("--list-common-symbols       List all symbols marked as common");
	writeln("--list-local-symbols        List all local symbols, if kept");
	writeln("--list-all-symbols          List all available symbols from an image");
	writeln("--no-list-macros            Suppress expansion of macros in list file");
	writeln("--no-line-numbers           Disable line number info in map file");
	writeln("--no-relocation             Disable relocatable code");
	writeln("--map <file>                Create map file in <file>");
	writeln("--max-allocation <bytes>    Specify maximum bytes to occupy in SRAM");
	writeln("-o, --output <file>         Specify name of output executable");
	writeln("-O <s|0|1>                  Set level of optimization");
	writeln("--overlay-defs <file>       Use <file> for overlay specifications");
	writeln("--pack                      Use run-length encoding to pack executable");
	writeln("--pack-code                 Combines code sections");
	writeln("--pack-data                 Combines data sections");
	writeln("--pack-functions            Performs \"smart-linking\"");
	writeln("--pool-size <bytes>         Override default literal pool size");
	writeln("-s, --strip                 Omit all symbol info from the output file");
	writeln("--script <file>             Use <file> to specify a linker script");
	writeln("--stack-max <bytes>         Define stack segment size");
	writeln("--stats                     Compute and display statistics about linker operation");
	writeln("-t, --trace                 Prints the names of the input files as ld processes them");
	writeln("--verify-relocation         Ensure no section overlaps");
	writeln("--lowercase                 Convert all instructions and operands to lowercase");
	writeln("--uppercase                 Convert all instructions and operands to uppercase");
	writeln("--ignorecase                (default) Don't be case sensitive");
	writeln("-v, --verbose               Be verbose in all output");
	writeln("--version <version>         Add a version string to the image");
	writeln("--xref                      Turn on detailed cross referencing in map file");
	writeln("-xz, --compress             Enable XZ image compression");
}
